//
//  WeatherViewController.m
//  FVQuickMessage
//
//  Created by dllo on 16/8/17.
//  Copyright © 2016年 zty. All rights reserved.
//

#import "WeatherViewController.h"
#import "WeatherView.h"
#import "CityViewController.h"

@interface WeatherViewController ()

@property (nonatomic, retain) WeatherView *weatherView;

@end

@implementation WeatherViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self config];
    
    [self createWeatherView];
    
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    
    
    
}

-(void)change:(UIBarButtonItem *)button {
    
    CityViewController *cityVC = [[CityViewController alloc] init];
    
    [self.navigationController pushViewController:cityVC animated:YES];
    
}

-(void)click:(UIBarButtonItem *)button {
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

-(void)config {
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(click:)];
    
    [self.navigationItem.leftBarButtonItem setTintColor:[UIColor whiteColor]];
    
    [self.navigationItem setHidesBackButton:YES];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"切换城市" style:UIBarButtonItemStyleDone target:self action:@selector(change:)];
    
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor whiteColor]];
}

-(void)createWeatherView {
    
    self.weatherView = [[WeatherView alloc] initWithFrame:self.view.bounds];
    
    self.weatherView.cityid = self.cityID;
    
    [self.view addSubview:self.weatherView];
    
}

-(void)setCityID:(NSString *)cityID {
    
    if (_cityID != cityID) {
        _cityID = cityID;
    }
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
